package com.huyn.baseframework.dynamicload;

import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

import com.ryg.dynamicload.internal.DLPluginPackage;

public abstract class DLViewGroup extends ViewGroup {
    private DLPluginPackage mPluginPackage;
    protected Context context;
    protected DLBridge mBridge;

    public DLViewGroup(Context context) {
        this(context, null);
    }
    public DLViewGroup(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }
    public DLViewGroup(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context = context;
    }

    public void injectPluginPackage(DLPluginPackage mPluginPackage) {
        this.mPluginPackage = mPluginPackage;

        initViews();
    }

    public abstract void initViews();

    public void onResume() {}

    public void onDestroy() {}

    public Resources getResources() {
        if(mPluginPackage == null)
            return super.getResources();
        return mPluginPackage.resources;
    }

    public void setDLBridge(DLBridge mBridge) {
        this.mBridge = mBridge;
    }

    public DLPluginPackage getDLPluginPackage() {
        return mPluginPackage;
    }

}
